CS450-FALL
2005
The
following directions apply to all assignments:
IMPORTANT:
FOLLOW THE FOLLOWING DIRECTIONS OR YOU RISK OF HAVING YOUR SUBMISSION NOT
GRADED!!!!!!!!
1.
Submit homework/project assignments to BLACKBOARD’s DIGITAL DROP BOX
only .
Include your source code files, WHEN APPLICABLE, compiled code, WHEN
APPLICABLE, executables, WHEN APPLICABLE, README file WHEN APPLICABLE, WORD
file with your text type answers etc as required (see 3 below).
2.
At the top of each source code file (if code is involved) include the
following comments: //Author: Your name //
Student
ID: your school ID// Assignment # : ___ // Problem#___//Date:
3.
All
assignments should include a WORD file named with the same name you use for the
zipped name (see
item 4). In the WORD file include : YOUR
NAME, YOUR STUDENT ID, YOUR
ASSIGNMENT
#, DATE SUBMITTED.
This WORD file also has the text answers to assignments or answers to project questions other than code (i.e. text exercises).
Include any
data if the assignment requires it. Any additional comments can be included in
the WORD file
(for example
special instructions as to how to execute your program IN CASE OF A PROGRAM).
4.
Create a folder and include all the assignment files in that folder.
Name that folder the same name as the zipped file described next. Zip all files
and use the following convention to name the zipped file:
yourlastname_assignment#.zip (for projects use yourlastname_project#.zip).
Upload the zipped file to the digital drop box of Blackboard.
NOTE: ASSIGNMENTS ARE BASED ON BOTH THE TEXT AND ANY HANDOUTS PRESENT ON THE COURSE”S WEB SITE
procedure P (c: integer)
x : integer
procedure Q (a, b : integer)
i , j : integer
begin
x : = x + a + j;
end ;
begin
Q (x, c );
end;
Currently the instruction that calls Q (x, c) is executed. Draw the Activation frames that are active in stack part of the memory. Label the frames by the name of the procedure they belong to. Show the contents of the frames and the corresponding addresses in stack. Assume fake decimal addresses as follows:
Beginning of stack (bottom part of stack) address 10000.
Beginning of text area 4000.
Each allocation takes 4 addresses.
Assume that each activation frame contains from the start to bottom: dynamic link, return address, static link, local variables, arguments to be passed to the next frame. Show the contents of the $fp and $sp registers as well as the contents of each address in the frames (note that in some cases dynamic and static links are the same). Show fake return addresses in the Activation Frames that relate to the proper area of memory.
Note: You have to assume that some main procedure is calling procedure P and that it is passing to it the variable c. Therefore for the main procedure show only the variable to be passed to P but allocate enough memory for it (also assume that only one local variable exists in main). The contents for the main can be empty but the addresses have to be correct.
2. Do exercise 3.4
1. Do exercise 3.6
1. Do exercise 3.9
In this exercise you are required to create an echo server with a GUI . Use the code and instructions provided to you during the corresponding lecture.
Also follow instructions given in class for setting the classpath environment variable.
Write a UNIX bash shell script that uses
pipes and tee commands to do the following:
§
First create a
file by the name myfile. Enter the text:
This is the day (new line)
That I am going to win (new line)
The lottery
§
The user
executes the script with one argument which is the name of a file. The name of
the script command should be pipesscript.src.
§
The script
searches for the lines that end in “y” and prints them on the screen while at
the same time puts the results of the search in the file named in the command’s
argument. (must use pipe and tee)
§
It then waits
for the user to press enter. When the user presses enter the entire content of
the file myfile is printed on the screen and also appended to the file name
din the command’s argument.
§
The user
terminates the script.
Write a C program, that :
Displays
the message :
Enter H for Help (describes how
to use your program. In particular, it describes the usage of P command and the
expected output)
Enter P to list the running processes and their owners (similar to ps
command output)
Enter P arg1 (to save the results in a file named in the arg1 of the
command)
Enter Q to quit
Command
line: (waits for the user the enter H
or P or Q)
After the
user enters a correct command and hits the Enter key, a new, separate child
process is created to execute the corresponding command. After completion
of the execution of the command, control is returned to the parent process
which in case of H or P displays again:
Command: (waits for the next command by the user)
In case of Q the program exits.
If anything else than H, P, Q is entered, the
program displays “Invalid Command”, repeats the initial message from part 1,
and waits for the next command by the user.
The program
should not terminate until the user enters the quit (Q) option (regardless how
long the user waits before entering a command).